package com.ruoyi.intelligence.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.intelligence.domain.SysEquipment;
import com.ruoyi.intelligence.service.ISysEquipmentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 设备列表Controller
 * 
 * @author ruoyi
 * @date 2020-08-26
 */
@RestController
@RequestMapping("/intelligence/equipment")
public class SysEquipmentController extends BaseController
{
    @Autowired
    private ISysEquipmentService sysEquipmentService;

    /**
     * 查询设备列表列表
     */
    @PreAuthorize("@ss.hasPermi('intelligence:equipment:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysEquipment sysEquipment)
    {
        startPage();
        List<SysEquipment> list = sysEquipmentService.selectSysEquipmentList(sysEquipment);
        return getDataTable(list);
    }

    /**
     * 导出设备列表列表
     */
    @PreAuthorize("@ss.hasPermi('intelligence:equipment:export')")
    @Log(title = "设备列表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysEquipment sysEquipment)
    {
        List<SysEquipment> list = sysEquipmentService.selectSysEquipmentList(sysEquipment);
        ExcelUtil<SysEquipment> util = new ExcelUtil<SysEquipment>(SysEquipment.class);
        return util.exportExcel(list, "equipment");
    }

    /**
     * 获取设备列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('intelligence:equipment:query')")
    @GetMapping(value = "/{equipmentId}")
    public AjaxResult getInfo(@PathVariable("equipmentId") Long equipmentId)
    {
        return AjaxResult.success(sysEquipmentService.selectSysEquipmentById(equipmentId));
    }

    /**
     * 新增设备列表
     */
    @PreAuthorize("@ss.hasPermi('intelligence:equipment:add')")
    @Log(title = "设备列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysEquipment sysEquipment)
    {
        return toAjax(sysEquipmentService.insertSysEquipment(sysEquipment));
    }

    /**
     * 修改设备列表
     */
    @PreAuthorize("@ss.hasPermi('intelligence:equipment:edit')")
    @Log(title = "设备列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysEquipment sysEquipment)
    {
        return toAjax(sysEquipmentService.updateSysEquipment(sysEquipment));
    }

    /**
     * 删除设备列表
     */
    @PreAuthorize("@ss.hasPermi('intelligence:equipment:remove')")
    @Log(title = "设备列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{equipmentIds}")
    public AjaxResult remove(@PathVariable Long[] equipmentIds)
    {
        return toAjax(sysEquipmentService.deleteSysEquipmentByIds(equipmentIds));
    }
}
